<?php
$action = $_REQUEST['action'];
	if(empty($action))
	{
		//载入GROUP
		$Res = $mysql -> prepare('SELECT * FROM `'.RC_DBTABLEPRE.'group`');
		$Res -> execute();
		$GroupList = $Res -> fetchAll();
		$Res -> closecursor();
		include_once(RC_TEMPLATESDIR.'createtable.htm');//载入HTML
	}
	
	if($action == 'add')
	{
		$title = $_REQUEST["title"];
		$group = $_REQUEST["group"];
		$rights = $_REQUEST["rights"];
		$javascript = $_REQUEST["javascript"];
		$note = $_REQUEST["note"];
		$culs = $_REQUEST["culs"];
		
		$starttime = mktime($_REQUEST['bh'],$_REQUEST['bi'],$_REQUEST['bs'],$_REQUEST['bm'],$_REQUEST['bd'],$_REQUEST['by']);
		$endtime = mktime($_REQUEST['eh'],$_REQUEST['ei'],$_REQUEST['es'],$_REQUEST['em'],$_REQUEST['ed'],$_REQUEST['ey']);
		
		$mysqlvars = array();
		$ins = explode('|||',$culs);
		for($i=0;isset($ins[$i]);$i++){
			$mysqlvars[$i] = $vars = explode('~~~',$ins[$i]);
			if(substr($vars[0],0,1) != 'i'){
				if($vars[1] == '1'){
					$Res = $mysql -> prepare('INSERT INTO `mp_inputbox` VALUES(NULL,?)');
					$Res -> execute(array($vars[2]));
					$Res -> closecursor();
					$mysqlvars[$i][0] = $mysql -> lastInsertId();
				}
			}
		}
		$varsstring = serialize($mysqlvars);
		$Res = $mysql -> prepare('INSERT INTO `mp_table` VALUES(NULL,?,?,?,?,?,?,?,?,?)');
		$Res -> execute(array($title,$varsstring,$starttime,$endtime,$group,$rights,$javascript,$note,UCID));
		$Res -> closecursor();
		header('Location:func.php?func=tablelist');
	}
?>